package com.htc.android.footprints.activity;

import java.io.File;
import java.io.IOException;

import android.app.Activity;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.hardware.Camera;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.StatFs;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.htc.android.footprints.ILocationAgentCallback;
import com.htc.android.footprints.ILocationAgentService;
import com.htc.android.footprints.R;
import com.htc.android.footprints.commonui.HtcDialog;
import com.htc.android.footprints.service.LocationAgentService;
import com.htc.android.footprints.utils.FootprintUtils;
import com.htc.android.footprints.utils.SettingInfo;
import com.htc.android.footprints.utils.SoundPlayer;
import com.htc.android.footprints.utils.StorageUtil;
import com.htc.android.footprints.utils.camera.FootprintImageManager;
import com.htc.android.footprints.view.BrightnessPanel;
import com.htc.android.footprints.vo.Category;

public class FootprintCamera extends Activity implements SurfaceHolder.Callback {
	private static final int BRIGHTNESS_BAR_TIME = 3000;
	private static final int FIRST_LAUNCH_DIALOG = 0;
	private static final int LOCATION_SOURCE_DISABLED_DIALOG = 1;
	private static int MENU_ADJUST_BRIGHT = 0;
	private static int MENU_ADJUST_WHITE_BALANCE = 0;
	private static int MENU_ALL_FOOTPRINTS = 0;
	private static final int RECAP_NONE = 0;
	private static final int SELECT_WHITE_BALANCE_DIALOG = 2;
	private static final int SERVICE_BINDED = 2;
	private static final int SERVICE_BINDING = 1;
	private static final int SERVICE_UNBIND = 0;
	private static final int S_COMPLETED = 5;
	private static final int S_FOCUSED = 3;
	private static final int S_FOCUSING = 2;
	private static final int S_IDLE = 0;
	private static final int S_PREVIEW = 1;
	private static final int S_SNAPSHOT = 4;
	private static final String TAG = "FootprintCamera";
	private static int whiteBalanceDefaultIndex;
	private boolean backFromSettings = false;
	private boolean gpsEnabled = false;
	private TextView tvLocation;
	boolean indicatorFlag = true;
	private boolean isForceSnap;
	private boolean isLanuchByWidget = false;
	private int isRecaputre;
	private String mAddress = null;
	private int mBindState = 0;
	private BrightnessPanel mBrightPanel;
	private ILocationAgentCallback mCallback = new ILocationAgentCallback.Stub() {
		public void onAgentPause() throws RemoteException {
			Log.w("FootprintCamera", "onAgentPause");
			if (FootprintCamera.this.mService != null)
				FootprintCamera.this.mService.stopTrackingWithoutNotify();
			FootprintCamera.this.finish();
		}

		public void onUpdateStatus(int paramInt1, int paramInt2,
				double paramDouble1, double paramDouble2)
				throws RemoteException {
			switch (paramInt1) {
			default:
			case 10:
			case 11:
			case 13:
			case 14:
			case 12:
			}
			while (true) {
				return;
				FootprintCamera.this.ivLocation.setVisibility(0);
				FootprintCamera.this.ivLocation.setImageLevel(paramInt2);
				FootprintCamera.this.tvLocation.setText(FootprintCamera.this
						.getString(2131361810));
				Log.d("FootprintCamera", "onUpdateStatus : INDICATOR_STOP");
				continue;
				FootprintCamera.this.tvLocation.setText(FootprintCamera.this
						.getString(2131361809));
				if (FootprintCamera.this.indicatorFlag)
					FootprintCamera.this.ivLocation.setImageLevel(paramInt2);
				for (FootprintCamera.this.indicatorFlag = false;; FootprintCamera.this.indicatorFlag = true) {
					FootprintCamera.this.ivLocation.setImageLevel(paramInt2);
					break;
					FootprintCamera.this.ivLocation.setImageLevel(0);
				}
				FootprintCamera.this.ivLocation.setVisibility(0);
				FootprintCamera.this.ivLocation.setImageLevel(paramInt2);
				String str1 = FootprintUtils
						.getFormatedLat((int) (1000000.0D * paramDouble1));
				String str2 = FootprintUtils
						.getFormatedLon((int) (1000000.0D * paramDouble2));
				String str3 = str1 + ", " + str2;
				FootprintCamera.this.tvLocation.setText(str3);
				if (FootprintCamera.this.mFixLocation == null)
					FootprintCamera.access$502(FootprintCamera.this,
							new Location("gps"));
				FootprintCamera.this.mFixLocation.setLatitude(paramDouble1);
				FootprintCamera.this.mFixLocation.setLongitude(paramDouble2);
				FootprintCamera.this.mService.stopTrackingWithoutNotify();
				Log.d("FootprintCamera", "onUpdateStatus : INDICATOR_FIX_GPS");
				continue;
				Log.d("FootprintCamera",
						"onUpdateStatus : INDICATOR_FIX_NETWORK");
				FootprintCamera.access$702(FootprintCamera.this, new Location(
						"network"));
				FootprintCamera.this.mFixNetwork.setLatitude(paramDouble1);
				FootprintCamera.this.mFixNetwork.setLongitude(paramDouble2);
				continue;
				FootprintCamera.this.mService.continueTracking();
				Log.d("FootprintCamera", "onUpdateStatus : INDICATOR_TIMEOUT");
			}
		}
	};
	private Camera mCameraDevice;
	private Handler mCheckBgHandler = new Handler();
	private ServiceConnection mConnection = new ServiceConnection() {
		public void onServiceConnected(ComponentName paramComponentName,
				IBinder paramIBinder) {
			Log.i("FootprintCamera",
					"onServiceConnected. mBindState = SERVICE_BINDED");
			FootprintCamera.this.mService = ILocationAgentService.Stub
					.asInterface(paramIBinder);
			FootprintCamera.access$2402(FootprintCamera.this, 2);
			try {
				Log.d("FootprintCamera",
						"mService.resume() at onServiceConnected");
				FootprintCamera.this.mService.resume();
				FootprintCamera.this.mService
						.registerCallback(FootprintCamera.this.mCallback);
				if (FootprintCamera.this.isRecaputre == 0) {
					if (FootprintCamera.this.gpsEnabled)
						FootprintCamera.this.mService.enableMyLocation();
				} else if (!FootprintCamera.this.mService.isTracking())
					FootprintCamera.this.ivLocation.setVisibility(4);
			} catch (RemoteException localRemoteException) {
				localRemoteException.printStackTrace();
			}
		}

		public void onServiceDisconnected(ComponentName paramComponentName) {
			Log.d("FootprintCamera",
					"onServiceDisconnected. mBindState = SERVICE_UNBIND");
			FootprintCamera.access$2402(FootprintCamera.this, 0);
		}
	};
	private Location mFixLocation = null;
	private Location mFixNetwork = null;
	private Handler mHandler = new Handler();
	private ImageCapture mImageCapture = null;
	private ImageView ivLocation = null;
	private String mNote = null;
	private String mPhone = null;
	private Category mSelectedCategory;
	ILocationAgentService mService = null;
	private SoundPlayer mSound;
	private int mStatus;
	private StorageUtil mStorageUtil;
	private SurfaceView mSurfaceView = null;
	private String mTitle = null;
	private String mUrl = null;
	public Runnable resetBrightnessPanel = new Runnable() {
		public void run() {
			Animation localAnimation = AnimationUtils.loadAnimation(
					FootprintCamera.this, 2130968582);
			localAnimation.setDuration(150L);
			FootprintCamera.this.mBrightPanel.startAnimation(localAnimation);
			FootprintCamera.this.mBrightPanel.setVisibility(8);
		}
	};
	private ImageView takeButton;
	private CharSequence[] whiteBalanceItems = null;
	private DialogInterface.OnClickListener whiteBalanceSelectionListener = null;
	private String[] whiteBalanceSettings = null;

	static {
		MENU_ADJUST_WHITE_BALANCE = 1;
		MENU_ADJUST_BRIGHT = 2;
		whiteBalanceDefaultIndex = 0;
	}

	private void autoFocus() {
		if ((this.mStatus == 2) && (this.mCameraDevice != null))
			this.mCameraDevice.autoFocus(new Camera.AutoFocusCallback() {
				public void onAutoFocus(boolean paramBoolean, Camera paramCamera) {
					if (!paramBoolean)
						;
					try {
						if (FootprintCamera.this.isForceSnap) {
							FootprintCamera
									.access$1602(FootprintCamera.this, 3);
							FootprintCamera.this.mSound.prepareCarmerFocused();
							FootprintCamera.this.mSound.play();
							FootprintCamera.this.mImageCapture.onSnap();
						} else {
							FootprintCamera
									.access$1602(FootprintCamera.this, 1);
							FootprintCamera.this.takePicture(true);
						}
					} catch (Exception localException) {
						localException.printStackTrace();
						FootprintCamera.this.finish();
					}
				}
			});
	}

	private void bindLocationAgentService() {
		Log.i("FootprintCamera",
				"bind LocationAgentService. mBindState = SERVICE_BINDING");
		this.mBindState = 1;
		Intent localIntent = new Intent();
		localIntent.setClass(this, LocationAgentService.class);
		bindService(localIntent, this.mConnection, 1);
	}

	private int calculatePicturesRemaining() {
		int i = -1;
		try {
			if (hasExternalStorage()) {
				StatFs localStatFs = new StatFs(Environment
						.getExternalStorageDirectory().toString());
				float f = localStatFs.getAvailableBlocks();
				int j = localStatFs.getBlockSize();
				i = (int) (f * j / 400000.0F);
			}
			return i;
		} catch (Exception localException) {
			while (true) {
				Log.e("FootprintCamera", localException.getMessage(),
						localException);
				i = -2;
			}
		}
	}

	private void checkInBackground() {
		Log.w("FootprintCamera", "checkInBackground");
		this.mCheckBgHandler.postDelayed(new Runnable() {
			public void run() {
				Log.w("FootprintCamera", "checkInBackground, thread run");
				if ((FootprintUtils.isOnBackground(FootprintCamera.this))
						&& (FootprintCamera.this.mService != null))
					;
				try {
					FootprintCamera.this.mService.stopTrackingWithoutNotify();
					Log.w("FootprintCamera", "InBackground, stop service");
					return;
				} catch (RemoteException localRemoteException) {
					while (true)
						localRemoteException.printStackTrace();
				}
			}
		}, 20000L);
	}

	private void checkLocationSources() {
		LocationManager localLocationManager = (LocationManager) getSystemService("location");
		this.gpsEnabled = localLocationManager.isProviderEnabled("gps");
		boolean bool = localLocationManager.isProviderEnabled("network");
		if (!this.gpsEnabled) {
			this.tvLocation.setText(getString(2131361812));
			this.ivLocation.setImageLevel(6);
		}
		if ((SettingInfo.getInstance(this).showLocationDisabledAlert)
				&& ((!this.gpsEnabled) || (!bool)))
			showDialog(1);
	}

	private void createWhiteBalanceMenu() {
		if (this.whiteBalanceSettings == null) {
			String[] arrayOfString = new String[7];
			arrayOfString[0] = "auto";
			arrayOfString[1] = "incandescent";
			arrayOfString[2] = "fluorescent";
			arrayOfString[3] = "daylight";
			arrayOfString[4] = "cloudy";
			arrayOfString[5] = "twilight";
			arrayOfString[6] = "shade";
			this.whiteBalanceSettings = arrayOfString;
		}
		if (this.whiteBalanceItems == null) {
			CharSequence[] arrayOfCharSequence = new CharSequence[7];
			arrayOfCharSequence[0] = getString(2131361925);
			arrayOfCharSequence[1] = getString(2131361926);
			arrayOfCharSequence[2] = getString(2131361927);
			arrayOfCharSequence[3] = getString(2131361928);
			arrayOfCharSequence[4] = getString(2131361929);
			arrayOfCharSequence[5] = getString(2131361930);
			arrayOfCharSequence[6] = getString(2131361931);
			this.whiteBalanceItems = arrayOfCharSequence;
		}
		if (this.whiteBalanceSelectionListener == null)
			this.whiteBalanceSelectionListener = new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface paramDialogInterface,
						int paramInt) {
					FootprintCamera.access$2002(paramInt);
					FootprintUtils.putWBPreferences(FootprintCamera.this,
							paramInt);
					String str = FootprintCamera.this.whiteBalanceSettings[paramInt];
					FootprintCamera.this.mHandler.post(new Runnable(str) {
						public void run() {
							FootprintUtils.setCameraWhiteBalance(
									FootprintCamera.this.mCameraDevice,
									this.val$settings);
						}
					});
					paramDialogInterface.dismiss();
				}
			};
		showDialog(2);
	}

	public static boolean hasExternalStorage() {
		return Environment.getExternalStorageState().equals("mounted");
	}

	private void innerUnbindLocationAgentService(boolean paramBoolean) {
		try {
			if (this.mService != null) {
				Log.d("FootprintCamera", "removeCallback");
				this.mService.removeCallback(this.mCallback);
				if (paramBoolean)
					this.mService.shutdownAgent();
			}
			unbindService(this.mConnection);
			this.mService = null;
			this.mBindState = 0;
			return;
		} catch (RemoteException localRemoteException) {
			while (true)
				localRemoteException.printStackTrace();
		}
	}

	private void takePicture(boolean paramBoolean) {
		if (this.mStatus == 1) {
			this.isForceSnap = paramBoolean;
			this.mStatus = 2;
			this.mSound.prepareCarmerFocusing();
			this.mSound.play();
			autoFocus();
		}
	}

	private void unbindLocationAgentService(boolean paramBoolean) {
		Log.i("FootprintCamera", "unbind LocationAgentService. mBindState = "
				+ this.mBindState);
		if (this.mBindState == 1) {
			Log.d("FootprintCamera",
					"LocationAgentService is still in binding. but user call unbind");
			innerUnbindLocationAgentService(paramBoolean);
		}
		while (true) {
			return;
			if (this.mBindState == 2) {
				innerUnbindLocationAgentService(paramBoolean);
				continue;
			}
			if (this.mBindState != 0)
				continue;
			Log.d("FootprintCamera",
					"LocationAgentService is not bind. but user call unbind");
		}
	}

	public void closeBrightnessPanel() {
		this.mHandler.removeCallbacks(this.resetBrightnessPanel);
		Animation localAnimation = AnimationUtils.loadAnimation(this,
				2130968582);
		localAnimation.setDuration(150L);
		this.mBrightPanel.startAnimation(localAnimation);
		this.mBrightPanel.setVisibility(8);
	}

	public void finish() {
		if (this.mCameraDevice != null) {
			this.mCameraDevice.stopPreview();
			this.mCameraDevice.release();
			this.mCameraDevice = null;
		}
		this.mStatus = 0;
		super.finish();
	}

	protected void onCreate(Bundle paramBundle) {
		super.onCreate(paramBundle);
		requestWindowFeature(1);
		requestWindowFeature(2);
		getWindow().clearFlags(128);
		Intent localIntent = getIntent();
		this.mSelectedCategory = ((Category) localIntent
				.getParcelableExtra("CATEGORY"));
		Log.i("FootprintCamera", "get category from parcel"
				+ this.mSelectedCategory);
		setContentView(R.layout.footprint_camera_layout);
		this.mSurfaceView = ((SurfaceView) findViewById(2131492950));
		SurfaceHolder localSurfaceHolder = this.mSurfaceView.getHolder();
		localSurfaceHolder.addCallback(this);
		localSurfaceHolder.setType(3);
		if (this.mSurfaceView.getKeepScreenOn())
			this.mSurfaceView.setKeepScreenOn(false);
		this.takeButton = ((ImageView) findViewById(take_button));
		if ((this.takeButton != null) && (this.takeButton.getVisibility() != 8)) {
			this.takeButton.setEnabled(hasExternalStorage());
			this.takeButton.setOnTouchListener(new View.OnTouchListener() {
				public boolean onTouch(View paramView,
						MotionEvent paramMotionEvent) {
					switch (paramMotionEvent.getAction()) {
					default:
					case 0:
					case 1:
					}
					while (true) {
						return true;
						FootprintCamera.this.takePicture(false);
						FootprintCamera.this.takeButton
								.setBackgroundResource(common_panel_navbar_button_selected);
						continue;
						FootprintCamera.this.takeButton
								.setBackgroundResource(common_panel_navbar_button_rest);
					}
				}
			});
		}
		this.isRecaputre = localIntent.getIntExtra("recapture", 0);
		this.ivLocation = ((ImageView) findViewById(location_indicator));
		this.tvLocation = ((TextView) findViewById(location_indicator_text));
		checkLocationSources();
		SettingInfo localSettingInfo = SettingInfo.getInstance(this);
		if (localSettingInfo.isFirstLaunch()) {
			showDialog(0);
			localSettingInfo.setFirstLaunch(false);
		}
		whiteBalanceDefaultIndex = FootprintUtils.getWBPreferences(this);
		this.mBrightPanel = ((BrightnessPanel) findViewById(2131492956));
		this.mBrightPanel.setCameraHandler(this.mHandler);
		this.isLanuchByWidget = localIntent.getBooleanExtra("LAUNCH_BY_WIDGET",
				false);
		Log.d("FootprintCamera", "isLanuchByWidget = " + this.isLanuchByWidget);
		if (this.gpsEnabled)
			bindLocationAgentService();
	}

	protected Dialog onCreateDialog(int paramInt) {
		Object localObject;
		switch (paramInt) {
		default:
			localObject = super.onCreateDialog(paramInt);
		case 0:
		case 1:
		case 2:
		}
		while (true) {
			return localObject;
			localObject = new HtcDialog(this).getWarningDialog();
			continue;
			localObject = new HtcAlertDialog.Builder(this)
					.setTitle(getString(2131361938))
					.setIcon(17301543)
					.setMessage(getString(2131361939))
					.setPositiveButton(2131361949,
							new DialogInterface.OnClickListener() {
								public void onClick(
										DialogInterface paramDialogInterface,
										int paramInt) {
									FootprintCamera.access$302(
											FootprintCamera.this, true);
									Intent localIntent = new Intent(
											"android.settings.LOCATION_SOURCE_SETTINGS");
									paramDialogInterface.dismiss();
									FootprintCamera.this
											.startActivity(localIntent);
								}
							}).setNegativeButton(2131361796, null).create();
			continue;
			localObject = new HtcAlertDialog.Builder(this)
					.setTitle(2131361923)
					.setIcon(2130837677)
					.setSingleChoiceItems(this.whiteBalanceItems,
							whiteBalanceDefaultIndex,
							this.whiteBalanceSelectionListener)
					.setNegativeButton(2131361796, null).create();
		}
	}

	public boolean onCreateOptionsMenu(Menu paramMenu) {
		paramMenu.add(0, MENU_ALL_FOOTPRINTS, MENU_ALL_FOOTPRINTS,
				getString(2131361881)).setIcon(2130837728);
		paramMenu.add(0, MENU_ADJUST_WHITE_BALANCE, MENU_ADJUST_WHITE_BALANCE,
				getString(2131361923)).setIcon(2130837699);
		paramMenu.add(0, MENU_ADJUST_BRIGHT, MENU_ADJUST_BRIGHT,
				getString(2131361924)).setIcon(2130837698);
		return true;
	}

	protected void onDestroy() {
		super.onDestroy();
		unbindLocationAgentService(false);
		this.mCallback = null;
		this.mImageCapture = null;
		this.mBrightPanel = null;
		this.mStorageUtil = null;
		this.mHandler = null;
		this.ivLocation.getDrawable().setCallback(null);
		this.ivLocation = null;
		this.mSurfaceView = null;
		this.mSound = null;
		if (this.takeButton != null) {
			if (this.takeButton.getDrawable() != null)
				this.takeButton.getDrawable().setCallback(null);
			this.takeButton.setOnClickListener(null);
			this.takeButton = null;
		}
	}

	public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent) {
		boolean bool;
		if (((paramInt == 23) || (paramInt == 66))
				&& (paramKeyEvent.getRepeatCount() == 0)) {
			takePicture(false);
			bool = true;
		}
		while (true) {
			return bool;
			if ((paramInt == 4) && (paramKeyEvent.getRepeatCount() == 0)) {
				if (this.mBrightPanel.getVisibility() == 0) {
					closeBrightnessPanel();
					bool = true;
					continue;
				}
				if (this.isRecaputre != 0)
					break;
			}
		}
		while (true) {
			try {
				if (this.mService == null)
					continue;
				this.mService.stopTracking();
				if (this.mCameraDevice == null)
					continue;
				this.mCameraDevice.stopPreview();
			} catch (RemoteException localRemoteException) {
				try {
					Thread.sleep(50L);
					bool = super.onKeyDown(paramInt, paramKeyEvent);
					break;
					localRemoteException = localRemoteException;
					localRemoteException.printStackTrace();
				} catch (InterruptedException localInterruptedException) {
					localInterruptedException.printStackTrace();
					continue;
				}
			}
			if (((paramInt != 19) && (paramInt != 20) && (paramInt != 21) && (paramInt != 22))
					|| (this.takeButton.isFocusable()))
				continue;
			this.takeButton.setFocusable(true);
		}
	}

	public boolean onOptionsItemSelected(MenuItem paramMenuItem) {
		int i = paramMenuItem.getItemId();
		if (i == MENU_ALL_FOOTPRINTS)
			startActivity(FootprintUtils.getResetIntent());
		while (true) {
			return true;
			if (i == MENU_ADJUST_WHITE_BALANCE) {
				createWhiteBalanceMenu();
				continue;
			}
			if (i != MENU_ADJUST_BRIGHT)
				continue;
			showBrightnessPanel();
			resetBrightnessPanel();
		}
	}

	protected void onPause() {
		if (this.mStorageUtil != null)
			this.mStorageUtil.closeStorgaeUtil();
		this.mSound.release();
		this.mSound = null;
		if (this.mService != null)
			;
		try {
			this.mService.waitForPause();
			super.onPause();
			return;
		} catch (RemoteException localRemoteException) {
			while (true)
				localRemoteException.printStackTrace();
		}
	}

	protected void onResume() {
		super.onResume();
		this.mImageCapture = new ImageCapture(null);
		if (this.mStorageUtil == null) {
			this.mStorageUtil = new StorageUtil(getApplicationContext());
			this.mStorageUtil
					.SetOnChangeStorageListerner(new StorageUtil.OnChangeStorageListener() {
						public void onStorageChanged(int paramInt) {
							if (paramInt > 1)
								FootprintCamera.this
										.startActivity(FootprintUtils
												.getResetIntent());
						}
					});
		}
		this.mSound = new SoundPlayer(this);
		if (this.mStorageUtil != null)
			this.mStorageUtil.startStorageUtil();
		if (this.mService != null)
			Log.d("FootprintCamera", "mService.resume() at onResume");
		try {
			this.mService.resume();
			if (this.backFromSettings) {
				this.backFromSettings = false;
				this.gpsEnabled = ((LocationManager) getSystemService("location"))
						.isProviderEnabled("gps");
				if ((this.gpsEnabled) && (this.mService == null))
					bindLocationAgentService();
			}
			return;
		} catch (RemoteException localRemoteException) {
			while (true)
				localRemoteException.printStackTrace();
		}
	}

	public void resetBrightnessPanel() {
		this.mHandler.removeCallbacks(this.resetBrightnessPanel);
		this.mHandler.postDelayed(this.resetBrightnessPanel, 3000L);
	}

	public void showBrightnessPanel() {
		if (this.mCameraDevice != null) {
			this.mBrightPanel.init(this.mCameraDevice, this.mHandler);
			this.mBrightPanel.showBrightPanel(0);
		}
	}

	public void surfaceChanged(SurfaceHolder paramSurfaceHolder, int paramInt1,
			int paramInt2, int paramInt3) {
		ViewGroup.LayoutParams localLayoutParams = this.mSurfaceView
				.getLayoutParams();
		localLayoutParams.width = paramInt2;
		localLayoutParams.height = paramInt3;
		this.mSurfaceView.requestLayout();
	}

	public void surfaceCreated(SurfaceHolder holder) {
		holder.setKeepScreenOn(false);
		if (this.mCameraDevice == null)
			this.mCameraDevice = Camera.open();
		try {
			this.mCameraDevice.setPreviewDisplay(holder);
			Camera.Parameters localParameters = this.mCameraDevice
					.getParameters();
			localParameters.setPreviewSize(240, 240);
			this.mCameraDevice.setParameters(localParameters);
			this.mCameraDevice.startPreview();
			this.mStatus = 1;
			return;
		} catch (IOException localIOException) {
			while (true)
				localIOException.printStackTrace();
		}
	}

	public void surfaceDestroyed(SurfaceHolder paramSurfaceHolder) {
		if (this.mCameraDevice != null) {
			this.mCameraDevice.stopPreview();
			this.mCameraDevice.release();
			this.mCameraDevice = null;
		}
		this.mStatus = 0;
	}

	private final class JpegPictureCallback implements Camera.PictureCallback {
		private JpegPictureCallback() {
		}

		public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera) {
			View localView = FootprintCamera.this.findViewById(2131492951);
			Animation localAnimation = AnimationUtils.loadAnimation(
					FootprintCamera.this.getApplicationContext(), 2130968580);
			localAnimation.setDuration(300L);
			localAnimation.setFillAfter(true);
			localView.startAnimation(localAnimation);
			FootprintCamera.this.mImageCapture.storeImage(paramArrayOfByte,
					paramCamera);
		}
	}

	private final class ShutterCallback implements Camera.ShutterCallback {
		private ShutterCallback() {
		}

		public void onShutter() {
			FootprintCamera.this.mSound.prepareCarmerShutter();
			FootprintCamera.this.mSound.play();
		}
	}

	private class ImageCapture {
		private ImageCapture() {
		}

		private void capture() {
			try {
				Camera.Parameters localParameters = FootprintCamera.this.mCameraDevice
						.getParameters();
				localParameters.set("jpeg-quality", 85);
				localParameters.setPictureSize(400, 400);
				localParameters.set("rotation", 90);
				FootprintCamera.this.mCameraDevice
						.setParameters(localParameters);
				FootprintCamera.this.mCameraDevice.takePicture(
						new FootprintCamera.ShutterCallback(
								FootprintCamera.this, null), null,
						new FootprintCamera.JpegPictureCallback(
								FootprintCamera.this, null));
				return;
			} catch (Exception localException) {
				while (true) {
					localException.printStackTrace();
					FootprintCamera.this.finish();
				}
			}
		}

		private void createFootprints(Uri paramUri) {
			if (FootprintCamera.this.isRecaputre == 2) {
				Intent localIntent1 = new Intent(FootprintCamera.this,
						PostcardActivity.class);
				localIntent1.setData(paramUri);
				localIntent1.putExtra("FIX_LOCATION",
						FootprintCamera.this.mFixLocation);
				FootprintCamera.this.setResult(-1, localIntent1);
				FootprintCamera.this.finish();
			}
			while (true) {
				return;
				if (FootprintCamera.this.isRecaputre == 1) {
					Intent localIntent2 = new Intent(FootprintCamera.this,
							DetailViewActivity.class);
					localIntent2.setData(paramUri);
					FootprintCamera.this.setResult(-1, localIntent2);
					FootprintCamera.this.finish();
					continue;
				}
				Intent localIntent3 = new Intent(FootprintCamera.this,
						PostcardActivity.class);
				localIntent3.putExtra("LAUNCH_BY_WIDGET",
						FootprintCamera.this.isLanuchByWidget);
				localIntent3.setData(paramUri);
				localIntent3.putExtra("FIX_LOCATION",
						FootprintCamera.this.mFixLocation);
				localIntent3
						.putExtra("TITLE_NAME", FootprintCamera.this.mTitle);
				localIntent3.putExtra("ADDRESS", FootprintCamera.this.mAddress);
				localIntent3.putExtra("PHONE", FootprintCamera.this.mPhone);
				localIntent3.putExtra("WEBSITE", FootprintCamera.this.mUrl);
				localIntent3.putExtra("CATEGORY",
						FootprintCamera.this.mSelectedCategory);
				Log.i("FootprintCamera", "put category to parcel: "
						+ FootprintCamera.this.mSelectedCategory);
				FootprintCamera.this.startActivity(localIntent3);
				FootprintCamera.this.finish();
			}
		}

		private void createFootprints(String paramString) {
			if (FootprintCamera.this.isRecaputre == 2) {
				Intent localIntent1 = new Intent(FootprintCamera.this,
						PostcardActivity.class);
				localIntent1.putExtra("EXTRA_PHOTO_PATH", paramString);
				localIntent1.putExtra("FIX_LOCATION",
						FootprintCamera.this.mFixLocation);
				FootprintCamera.this.setResult(-1, localIntent1);
				FootprintCamera.this.finish();
			}
			while (true) {
				return;
				if (FootprintCamera.this.isRecaputre == 1) {
					Intent localIntent2 = new Intent(FootprintCamera.this,
							DetailViewActivity.class);
					localIntent2.putExtra("EXTRA_PHOTO_PATH", paramString);
					FootprintCamera.this.setResult(-1, localIntent2);
					FootprintCamera.this.finish();
					continue;
				}
				Intent localIntent3 = new Intent(FootprintCamera.this,
						PostcardActivity.class);
				localIntent3.putExtra("LAUNCH_BY_WIDGET",
						FootprintCamera.this.isLanuchByWidget);
				localIntent3.putExtra("EXTRA_PHOTO_PATH", paramString);
				localIntent3.putExtra("FIX_LOCATION",
						FootprintCamera.this.mFixLocation);
				localIntent3.putExtra("FIX_NETWORK",
						FootprintCamera.this.mFixNetwork);
				localIntent3
						.putExtra("TITLE_NAME", FootprintCamera.this.mTitle);
				localIntent3.putExtra("ADDRESS", FootprintCamera.this.mAddress);
				localIntent3.putExtra("PHONE", FootprintCamera.this.mPhone);
				localIntent3.putExtra("WEBSITE", FootprintCamera.this.mUrl);
				localIntent3.putExtra("CATEGORY",
						FootprintCamera.this.mSelectedCategory);
				Log.i("FootprintCamera", "put category to parcel: "
						+ FootprintCamera.this.mSelectedCategory);
				FootprintCamera.this.startActivity(localIntent3);
				FootprintCamera.this.finish();
			}
		}

		public void onSnap() {
			if ((StorageUtil.isExternalStorageEnough())
					&& (StorageUtil.isInternalStorageEnough())) {
				FootprintCamera.access$1602(FootprintCamera.this, 4);
				FootprintCamera.this.mImageCapture.capture();
			}
			while (true) {
				return;
				FootprintCamera.access$1602(FootprintCamera.this, 1);
				FootprintUtils.showToast(
						FootprintCamera.this,
						FootprintCamera.this.getResources().getString(
								2131361887));
			}
		}

		public void storeImage(byte[] paramArrayOfByte, Camera paramCamera) {
			try {
				String str1 = String.valueOf(System.currentTimeMillis());
				String str2 = str1 + ".jpg";
				FootprintImageManager.getInstance().forceWriteToFile(
						FootprintCamera.this.getContentResolver(),
						paramArrayOfByte, str2);
				createFootprints(FootprintImageManager.getDirectory()
						+ File.separator + str2);
				return;
			} catch (Exception localException) {
				while (true)
					Log.e("FootprintCamera",
							"Exception while compressing image.",
							localException);
			}
		}
	}
}

/*
 * Location:
 * E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name: com.htc.android.footprints.activity.FootprintCamera JD-Core
 * Version: 0.6.0
 */